package hu.rsc.feeds.client.data;

import java.util.HashMap;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.MenuItem;

/**
 * 
 * @author arbuckle
 */
public class Dictionary {

    private static DictionaryDto ENTRIES;

    public static final String LABEL_LANG = "langu";
    public static final String LABEL_LANG_HU = "langu_hu";
    public static final String LABEL_LANG_EN = "langu_en";
    public static final String LABEL_WELCOME = "label_welcome";
    public static final String LABEL_LOGINNAME = "label_loginname";
    public static final String LABEL_PASSWORD = "label_password";
    public static final String LABEL_MAIL = "label_mail";
    public static final String LABEL_ROWCOUNT = "label_rowcount";
    public static final String LABEL_COLCOUNT = "label_colcount";
    public static final String LABEL_ADD_NEW_CATEGORY = "label_add_catagory";
    public static final String LABEL_CATEGORY_NAME = "label_category_name";
    public static final String LABEL_DESCRIPTION = "label_chanel_description";
    public static final String LABEL_ADD_CHANEL = "label_add_chanel";
    public static final String LABEL_CHANEL = "label_chanel";
    public static final String LABEL_TAB = "label_tab";
    public static final String LABEL_OFFER_CHANEL = "label_offer_chanel";
    public static final String LABEL_CHANEL_name = "label_chanel_name";
    public static final String LABEL_CHANEL_URL = "label_chanel_url";
    public static final String LABEL_CATEGORY = "label_category";
    public static final String LABEL_ADD_TAB = "label_add_tab";
    public static final String LABEL_TAB_NAME = "label_tab_name";
    public static final String LABEL_DETAILS_LINK = "label_details_link";
    public static final String LABEL_SHARE_LINK = "label_share_link";
    public static final String LABEL_COUNTDOWN = "label_countdown";
    public static final String LABEL_GEN_TITLE = "label_generated_title";
    public static final String LABEL_GEN_APPLICATION = "label_generated_application";
    public static final String LABEL_GEN_ISHELP = "label_generated_ishelp";
    public static final String LABEL_GEN_AUTHOR = "label_generated_author";
    public static final String LABEL_GEN_DATE = "label_generated_pubdate";
    public static final String LABEL_GEN_SUMMARY = "label_generated_sum";
    public static final String LABEL_GEN_DESC = "label_generated_desc";
    public static final String LABEL_GEN_LINK = "label_generated_link";
    public static final String LABEL_GEN_CHANNEL_URL = "label_generated_url";
    public static final String LABEL_GEN_CONTEXT_CHANNEL_URL = "label_generated_context_url";
    public static final String LABEL_TABLE_FEED = "label_table_feed";
    public static final String LABEL_TABLE_SYSTEM = "label_table_system";
    public static final String LABEL_TABLE_ENTRY = "label_table_entry";
    public static final String LABEL_EMPTY_TABLE_FEED = "label_empty_table_feed";
    public static final String LABEL_EMPTY_TABLE_SYSTEM = "label_empty_table_system";
    public static final String LABEL_EMPTY_TABLE_ENTRY = "label_empty_table_entry";
    public static final String LABEL_NEED_NEWFEED_MAIL = "label_need_newfeed_mail";
    public static final String LABEL_EMPTY_TABLE_OFFERED = "label_empty_table_offered";
    public static final String LABEL_TABLE_OFFERED = "label_table_offered";
    public static final String LABEL_XSL = "label_xsl";

    public static final String BUTTON_LOGIN = "button_login";
    public static final String BUTTON_REGISTER = "button_register";
    public static final String BUTTON_LOGOUT = "button_logout";
    public static final String BUTTON_SETTINGS = "button_settings";
    public static final String BUTTON_PROFILE = "button_profile";
    public static final String BUTTON_ADD_FEED = "button_addfeed";
    public static final String BUTTON_SAVE_STATE = "button_save_state";
    public static final String BUTTON_OFFER = "button_offer";
    public static final String BUTTON_ADD_CATEGORY = "button_addcategory";
    public static final String BUTTON_ADD_TAB = "button_addtab";
    public static final String BUTTON_EDIT_PROFILE = "button_editprofile";
    public static final String BUTTON_OWN_CHANELS = "button_own_feeds";
    public static final String BUTTON_SYSTEM_CHANELS = "button_system_feeds";
    public static final String BUTTON_FILTER = "button_filter";
    public static final String BUTTON_FILTER_CANCEL = "button_filter_cancel";
    public static final String BUTTON_FILTER_DELETE = "button_filter_delete";
    public static final String BUTTON_NEW_CHANNEL = "button_new_feed";
    public static final String BUTTON_NEW_ARTICLE = "button_new_article";
    public static final String BUTTON_NEW_SYSTEM_CHANEL = "button_new_system_feed";
    public static final String BUTTON_NEW_SYSTEM_ENTRY = "button_new_system_entry";
    public static final String BUTTON_DELETE = "button_delete";
    public static final String BUTTON_OFFERED_CHANELS = "button_offered_feeds";
    public static final String BUTTON_DEMO_LOGIN = "button_demo_login";
    public static final String BUTTON_UPLOAD = "button_upload";

    public static final String TITLE_REGISTER = "title_register";
    public static final String TITLE_SETTINGS = "title_settings";
    public static final String TITLE_OWN_FEEDS = "title_own_feeds";
    public static final String TITLE_SYSTEM_FEEDS = "title_system_feeds";
    public static final String TITLE_FILTER = "title_filter";
    public static final String TITLE_OFFERED_FEEDS = "title_offered_feeds";

    public static final String MESSAGE_REG_ERROR = "message_reg_error";
    public static final String MESSAGE_EXISTED_USER = "message_existed_user";
    public static final String MESSAGE_USERNAME_LENGTH = "message_name_lengt";
    public static final String MESSAGE_PASSWORD_LENGTH = "message_pass_length";
    public static final String MESSAGE_MAIL_REQUIRED = "message_mail_required";
    public static final String MESSAGE_INVALID_ROWNUMBER = "message_invalid_rowcount";
    public static final String MESSAGE_INVALID_COLNUMBER = "message_invalid_colcount";
    public static final String MESSAGE_LOGINNAME_REQUIRED = "message_loginname_required";
    public static final String MESSAGE_INVALID_LOGIN = "message_invalid_login";
    public static final String MESSAGE_INVALID_DATAS = "message_invalid_datas";
    public static final String MESSAGE_COMM_ERROR = "message_comm_error";
    public static final String MESSAGE_OFFER_ERROR = "message_offer_error";
    public static final String MESSAGE_CATEGORYNAME_REQUIRED = "message_categoryname_required";
    public static final String MESSAGE_CATEGORY_EXISTED = "message_category_existed";
    public static final String MESSAGE_OWNED_FEED = "message_owned_feed";
    public static final String MESSAGE_NO_FREECELL = "message_no_freecell";
    public static final String MESSAGE_TABNAME_REQUIRED = "message_tabname_required";
    public static final String MESSAGE_EXISTED_TAB = "message_existed_tab";
    public static final String MESSAGE_SHARE_PROMPT = "message_share_prompt";
    public static final String MESSAGE_INVALID_EMAIL = "message_invalid_email";
    public static final String MESSAGE_AUTHOR_REQUIRED = "message_author_required";
    public static final String MESSAGE_TILE_REQUIRED = "message_title_required";
    public static final String MESSAGE_PUBDATE_REQUIRED = "message_pubdate_required";
    public static final String MESSAGE_NO_SELECTED_CHANNEL = "message_no_selected_feed";
    public static final String MESSAGE_SAME_APP = "message_same_app";
    public static final String MESSAGE_HAS_TYPE = "message_has_type";
    public static final String MESSAGE_SAVE_SUCCESS = "message_save_success";
    public static final String MESSAGE_DELETE_ERROR = "message_delete_error";
    public static final String MESSAGE_DIFFERENT_LANGUAGE = "message_diff_lang";

    public static final String YES = "yes";
    public static final String NO = "no";

    public static HashMap<Object, String> components = new HashMap<Object, String>();

    public static String getEntry(String key, Object component) {
	if (component != null) {
	    components.put(component, key);
	}
	return ENTRIES != null ? ENTRIES.getProperty(key) : null;
    }

    public static void refresh() {
	for (Object w : components.keySet()) {
	    if (w == null) {
		continue;
	    }
	    if (w instanceof Label) {
		((Label) w).setText(getEntry(components.get(w), w));
	    } else if (w instanceof Button) {
		((Button) w).setText(getEntry(components.get(w), w));
	    } else if (w instanceof MenuItem) {
		((MenuItem) w).setText(getEntry(components.get(w), w));
	    } else if (w instanceof CheckBox) {
		((CheckBox) w).setText(getEntry(components.get(w), w));
	    } else if (w instanceof DialogBox) {
		((DialogBox) w).setText(getEntry(components.get(w), w));
	    }
	}
    }

    public static void setEntries(DictionaryDto dto) {
	Dictionary.ENTRIES = dto;
    }
}
